<template>
	<div>
		<a-descriptions class="descri">
			<a-descriptions-item label="应用关键字">{{ pcConfig.appInfoKeywords }}</a-descriptions-item>
			<a-descriptions-item label="版本说明">{{ pcConfig.pcVersionNote }}</a-descriptions-item>
			<a-descriptions-item label="是否展示图标">{{ filterRadio(pcConfig.isHideLogo) }}</a-descriptions-item>
			<!-- <a-descriptions-item label="门户端应用上线时间">{{ pcConfig.pcOnlineTime }}</a-descriptions-item> -->
			<!-- <a-descriptions-item label="版本说明">{{ pcConfig.pcVersionNote }}</a-descriptions-item> -->
			<a-descriptions-item label="是否鉴权">{{ filterRadio(pcConfig.isAuth) }}</a-descriptions-item>
			<a-descriptions-item label="是否单点">{{ filterRadio(pcConfig.isSinglepoint) }}</a-descriptions-item>
			<a-descriptions-item label="单点地址">{{ pcConfig.singlepointUrl || '无' }}</a-descriptions-item>
			<a-descriptions-item label="应用地址">{{ pcConfig.appUrl || '无' }}</a-descriptions-item>
			<a-descriptions-item label="应用简称">{{ pcConfig.appShortName || '无' }}</a-descriptions-item>
			<a-descriptions-item label="应用教程">{{ pcConfig.appTutorials || '无' }}</a-descriptions-item>
			<a-descriptions-item label="批量已阅地址">{{ pcConfig.batchReadUrl || '无' }}</a-descriptions-item>
		</a-descriptions>
		<a-descriptions>
			<a-descriptions-item label="待办所属分类">{{
				pcConfig.pendingCategory ? $TOOL.dictTypeData('TODO_TYPE', pcConfig.pendingCategory) : ''
			}}</a-descriptions-item>
			<a-descriptions-item label="待办稽核地址">{{ pcConfig.pendingDatasourceUrl }}</a-descriptions-item>
			<a-descriptions-item label="数据库类型">{{ pcConfig.pendingDatasourceType }}</a-descriptions-item>
			<a-descriptions-item label="数据库账号">{{ pcConfig.pendingDatasourceUsername }}</a-descriptions-item>
			<!-- <a-descriptions-item label="数据库密码">{{
				filtPasword(pcConfig.pendingDatasourcePassword)
			}}</a-descriptions-item> -->
			<!-- <a-input-password v-model:value="pcConfig.pendingDatasourcePassword" disabled/> -->
			<a-descriptions-item label="待办核视图地址">{{ pcConfig.pendingTablename }}</a-descriptions-item>
			<a-descriptions-item label="对端系统管理人邮箱">{{ pcConfig.pendingUserMail }}</a-descriptions-item>
		</a-descriptions>
		<a-descriptions>
			<a-descriptions-item label="待阅所属分类">{{
				pcConfig.readingCategory ? $TOOL.dictTypeData('TODO_TYPE', pcConfig.readingCategory) : ''
			}}</a-descriptions-item>
			<a-descriptions-item label="待阅稽核地址">{{ pcConfig.readingDatasourceUrl }}</a-descriptions-item>
			<a-descriptions-item label="数据库类型">{{ pcConfig.readingDatasourceType }}</a-descriptions-item>
			<a-descriptions-item label="数据库账号">{{ pcConfig.readingDatasourceUsername }}</a-descriptions-item>
			<!-- <a-descriptions-item label="数据库密码">{{
				filtPasword(pcConfig.readingDatasourcePassword)
			}}</a-descriptions-item> -->
			<a-descriptions-item label="待阅核视图地址">{{ pcConfig.readingTablename }}</a-descriptions-item>
			<a-descriptions-item label="对端系统管理人邮箱">{{ pcConfig.readingUserMail }}</a-descriptions-item>
		</a-descriptions>
		<a-descriptions>
			<a-descriptions-item label="兼容性">{{ pcConfig.compatibility }}</a-descriptions-item>
			<a-descriptions-item label="认证状态">{{
				$TOOL.dictTypeData('CERTIFIED', pcConfig.authType)
			}}</a-descriptions-item>
			<a-descriptions-item v-if="pcConfig.taskTime" label="应用上线时间">{{ pcConfig.taskTime }}</a-descriptions-item>
			<a-descriptions-item label="下架原因" v-if="showRea">{{ pcConfig.reason }}</a-descriptions-item>
			<a-descriptions-item label="门户端应用logo">
				<!-- <img class="img-sty" :src="pcLogo" @click="handlePreview(pcLogo)" /> -->
				<AuthImg class="img-item" :authSrc="pcLogo" />
			</a-descriptions-item>
		</a-descriptions>
		<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
			<img alt="example" style="width: 100%" :src="imageUrl" />
		</a-modal>
	</div>
</template>

<script setup name="PcConfig">
import tool from '@/utils/tool'
import sysConfig from '@/config/index'
import { useRoute } from 'vue-router'
import AuthImg from '@/components/authImg/index.vue'
const route = useRoute()
const isTest = route.query.isTest
const datas = inject('detailDate')
const pcConfig = isTest ? datas.value?.appInfoPcPropertiesAddParam : datas.value?.pcPropertiesList[0] ? datas.value?.pcPropertiesList[0] : {}
const fileUrl = import.meta.env.VITE_FILE_URL_W
const pcLogo = computed(() => {
	let str = ''
	if (pcConfig.pcLogo && pcConfig.pcLogo.includes('group')) {
		str = `${sysConfig.FULL_URL}${pcConfig.pcLogo}`
	} else {
		str = `${fileUrl}/${pcConfig.pcLogo ? JSON.parse(pcConfig.pcLogo)[0].url : ''}`
	}
	return str
})
const showRea = computed(() => {
	let bool = false
	const approvalType = tool.session.get('approvalType')
	const doneStatus = tool.session.get('doneStatus')
	if ((approvalType === '0' || approvalType === '8') && !doneStatus) {
		bool = true
	}
	return bool
})
// 单选option
const radioOption = [
	{ label: '是', value: '1' },
	{ label: '否', value: '0' }
]
// 单选数据过滤
const filterRadio = (val) => {
	if (val) {
		const obj = radioOption.find((item) => item.value == val)
		return obj.label
	}
}
// 格式化密码
const filtPasword = (password) => {
	let str = ''
	if (password) {
		str = new Array(password.length).fill('*').join().replace(/,/g, '')
	}
	return str
}

const imageUrl = ref('')
let previewVisible = ref(false)
const handlePreview = (url) => {
	imageUrl.value = url
	previewVisible.value = true
}
const handleCancel = () => {
	previewVisible.value = false
}
</script>

<style lang="less" scoped>
.descri {
	margin-top: 10px;
}

.img-sty {
	width: 104px;
	height: 104px;
	cursor: pointer;
}
</style>
